package com.sgb.kjwl.view.ui.activity.self.logistics;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.InputType;
import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;

import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.bigkoo.pickerview.view.TimePickerView;
import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityCarrierBargainingBinding;
import com.sgb.kjwl.di.self.DaggerSelfComponent;
import com.sgb.kjwl.di.self.SelfModule;
import com.sgb.kjwl.model.entity.self.CarriageSelectEntity;
import com.sgb.kjwl.model.entity.self.GoodsSelectEntity;
import com.sgb.kjwl.model.entity.transport.GoodsInfoTypeEntity3;
import com.sgb.kjwl.model.entity.transport.MapGoodsBiddingEntity;
import com.sgb.kjwl.model.entity.user.AddressEntity;
import com.swgk.core.view.CityPickBuilder;
import com.swgk.core.view.CityPickView;
import com.sgb.kjwl.view.widget.GoodsSourceWindow;
import com.sgb.kjwl.viewmodel.self.logistics.OverbookingPublishModel;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.customview.ItemInputTextView;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.util.DateUtils;
import com.swgk.core.util.MLog;
import com.swgk.core.util.MToast;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.inject.Inject;

/*
* 下单发布
*
* 承运商机---》下单发布
*
* 1 activity类   2 项目清单配置   3 对应布局  4 适配器  5 每一项布局   6 网络请方法  7 数据模型
 * */
public class OverbookingPublishActivity   extends AppActivity implements ItemInputTextView.OnWholeItemClickListener{


    @Inject
    OverbookingPublishModel viewModel;
    ActivityCarrierBargainingBinding binding;//下单发布的 对应布局



    List<GoodsSelectEntity> goodsList;//货物类型 数据
    private int goodsModelPosition;
    private int isDumpPosition;

    // 一级联动数据
    private List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> addressEntityList;
    private boolean isLoaded = false;
    // 二级联动数据
    private List<List<AddressEntity<List<AddressEntity>>>> opt2;
    // 三级联动数据
    private List<List<List<AddressEntity>>> opt3;
    private int cityPosition1;
    private int cityPosition2;
    private int cityPosition3;

    private Thread thread;
    private static final int MSG_LOAD_DATA = 0x0001;
    private static final int MSG_LOAD_SUCCESS = 0x0002;
    private static final int MSG_LOAD_FAILED = 0x0003;
    private Calendar selectedDate;

    int choose;//两个共用的一个控件切换形式
    int time;//两个共用的一个控件切换形式
    private Date today;
    private List<CarriageSelectEntity> carModelList;//要求车型
    private List<CarriageSelectEntity> carLengthList;//我的车长
    private int carModelPosition;
    private List<CarriageSelectEntity> isDumpList;//是否自卸的数据
    private int carLengthPosition;
    public List<GoodsInfoTypeEntity3> handlingType;
    private int handlingTypePosition;
    List<GoodsInfoTypeEntity3> PayType;
    private int PayTypePosition;
    List<CarriageSelectEntity> InvoiceType;
    private int InvoiceTypePosition;
    public List<GoodsInfoTypeEntity3> TransType;
    private int TransTypePosition;
    //选择货源的数据
    List<MapGoodsBiddingEntity> goodsSourceList;

    private GoodsSourceWindow goodsSourceWindow;
    MapGoodsBiddingEntity entity;





    public static void start(Context context,String type) {
        Intent intent = new Intent(context, OverbookingPublishActivity.class);
        intent.putExtra("type",type);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        context.startActivity(intent);
    }




    @Override// 1  注入viewmodel
    protected void setupActivityComponent(AppComponent appComponent) {
        // selfmodule 3个配置                                   //1个配置
        DaggerSelfComponent.builder().appComponent(appComponent).selfModule(new SelfModule(this)).build().inject(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(OverbookingPublishActivity.this, R.layout.activity_carrier_bargaining);


        binding.backView.setOnClickListener(this);
        binding.nextView.setOnClickListener(this);

        binding.itemTvGoodsType.setOnWholeItemClickListener(this);//货物类型
        binding.itemTvDeliveryAddress.setOnWholeItemClickListener(this);//发货地
        binding.itemTvPurposeAddress.setOnWholeItemClickListener(this);//目的地
        binding.itemTvStartTime.setOnWholeItemClickListener(this);//开始时间
        binding.itemTvEndTime.setOnWholeItemClickListener(this);//结束时间
        binding.itemTvUnloadingWay.setOnWholeItemClickListener(this);//装卸方式
        binding.itemTvRequirementsModels.setOnWholeItemClickListener(this);//要求车型
        binding.itemTvDump.setOnWholeItemClickListener(this);//是否自卸

        binding.itemTvRequirementsConductor.setOnWholeItemClickListener(this);//要求车长  requirements_conductor
        binding.itemTvTermsPayment.setOnWholeItemClickListener(this);//付款方式
        binding.itemTvQualificationRequirements.setOnWholeItemClickListener(this);//资质要求
        binding.itemTvInvoiceRequirements.setOnWholeItemClickListener(this);//发票要求
        binding.itemTvTransportRequirements.setOnWholeItemClickListener(this);//运输要求
        binding.itemTvChooseGoods.setOnWholeItemClickListener(this);//选择货源  ======是一个列表显示




        //直接输入的文本宽
        binding.itemTvGoodsCarat.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvFreightPrice.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvFreightPrice.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvTermsPayment.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvQualificationRequirements.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvContact.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvPhone.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvHighBar.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);//栏高米


        if(getIntent().getStringExtra("type").equals("1")){
            binding.tVTitle.setText("议价");
          //  MToast.showToast(OverbookingPublishActivity.this, "议价测试");
        }else {
            binding.tVTitle.setText("下单");
          //  MToast.showToast(OverbookingPublishActivity.this, "下单测试");
        }


        goodsSourceWindow = new GoodsSourceWindow(this);
        goodsSourceWindow.setBgView(binding.grayLayout);
        goodsSourceWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object type, Object key2, Object key3) {

                viewModel.sourceDetailEntity.set((MapGoodsBiddingEntity)type);
                entity = (MapGoodsBiddingEntity)type;
                binding.itemTvChooseGoods.setContent(entity.getCityName() + " "+ entity.getDistrictName() + "->" + entity.getDestCityName() + " "+ entity.getDestDistrictName());


            }
        });

    }


    @Override
    protected void init() {
        super.init();
        opt2 = new ArrayList<>();
        opt3 = new ArrayList<>();
        selectedDate = Calendar.getInstance();
    }

    @Override
    public void OnWholeItemClick(View view) {
        MLog.e("madong","0000=====");
        switch (view.getId()){

            case R.id.item_tv_goods_type://货物类型
                if(carModelList != null){
                    showGoodsType();
                }else {
                    viewModel.goodsType();
                }
                break;
            case R.id.item_tv_delivery_address://发货地
                choose=1;
                if(addressEntityList != null){
                    showCityPop();
                }else {
                    viewModel.getAddressModel();
                }
                break;

            case R.id.item_tv_purpose_address://目的地
                choose=2;
                if(addressEntityList != null){
                    showCityPop();
                }else {
                    viewModel.getAddressModel();
                }
                break;

//            case R.id.item_tv_goods_carat://货物重量
//                break;

            case R.id.item_tv_start_time://装货时间开始
                time=1;
                showTimePop();
                break;

            case R.id.item_tv_end_time://卸货时间结束
                time=2;
                showTimePop();
                break;

            case R.id.item_tv_unloading_way://卸载方式
                if (isDumpList != null) {
                } else {
                    viewModel.getHandleType();
                }
                break;

            case R.id.item_tv_requirements_models://要求车型
                if (carModelList != null) {
                    showCarModelPop();
                } else {
                    viewModel.carType();
                }
                break;

            case R.id.item_tv_requirements_conductor://要求车长
                if (carLengthList != null) {
                    showCarLengthPop();
                } else {
                    viewModel.carLenType();
                }
                break;

            case R.id.item_tv_dump://是否自卸
                if (isDumpList != null) {
                    showIsDumpPop();
                } else {
                    viewModel.isDump();
                }
                break;

            case R.id.item_tv_terms_payment://付款方式
                if (PayType != null) {
                    showPayType();
                } else {
                    viewModel.getPayType();
                }
                break;

            case R.id.item_tv_invoice_requirements://发票要求
                if (InvoiceType != null) {
                    showInvoiceType();
                } else {
                    viewModel.invoiceType();
                }
                break;

            case R.id.item_tv_transport_requirements://运输要求
                if (TransType != null) {
                    showTransType();
                } else {
                    viewModel.getTransType();
                }
                break;

            case R.id.item_tv_choose_goods://选择货源  事件
                if (goodsSourceList != null){
                    showGoodsPop(false);
                } else {
                    viewModel.getGoodsSourceModel();
                }
                break;
        }

    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back_view:
                finish();
                break;
            case R.id.next_view:
                if (TextUtils.isEmpty(binding.itemTvGoodsType.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择货物类型");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvDeliveryAddress.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择目的地");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvPurposeAddress.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择目的地");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvGoodsCarat.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请输入货物重量");
                    return;
                } else if (binding.itemTvFreightPrice.getContent().equals("0")) {
                    MToast.showToast(OverbookingPublishActivity.this, "请输入运费单价");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvStartTime.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择开始时间");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvEndTime.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择结束时间");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvUnloadingWay.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择几装几卸");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvLoadingPlace.getEditContent())) {//备注输入内容的模块
                    MToast.showToast(OverbookingPublishActivity.this, "请输入装货地点");
                    return;
                }else if (TextUtils.isEmpty(binding.itemTvRequirementsModels.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择车型");
                    return;
                } else if (binding.itemTvHighBar.getContent().equals("0")) {
                    MToast.showToast(OverbookingPublishActivity.this, "请输入栏高");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvRequirementsConductor.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择车长");
                    return;
                }
                else if (TextUtils.isEmpty(binding.itemTvDump.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择是否自卸");
                    return;
                }
                else if (TextUtils.isEmpty(binding.itemTvTermsPayment.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择付款方式");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvQualificationRequirements.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请输入资质");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvInvoiceRequirements.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择发票要求");
                    return;
                } else if (TextUtils.isEmpty(binding.itemTvTransportRequirements.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请选择零担或整车");
                    return;
                } else  if (TextUtils.isEmpty(binding.itemTvNote.getEditContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请输入备注信息");
                    return;
                }  else if (TextUtils.isEmpty(binding.itemTvContact.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请输入联系人");
                    return;
                } else  if (TextUtils.isEmpty(binding.itemTvPhone.getContent())) {
                    MToast.showToast(OverbookingPublishActivity.this, "请输入手机号");
                    return;
                }

                //装货地点
                viewModel.releaseGoodsEntityObservableField.get().setNote(binding.itemTvLoadingPlace.getEditContent());
                //viewModel.releaseGoodsSubmit();
                //备注
                viewModel.releaseGoodsEntityObservableField.get().setNote(binding.itemTvNote.getEditContent());


                if(getIntent().getStringExtra("type").equals("1")){//议价
                    viewModel.bargining();
                //    MToast.showToast(OverbookingPublishActivity.this, "议价接口测试");
                }else {
                    viewModel.ordering();
                  //  MToast.showToast(OverbookingPublishActivity.this, "下单接口测试");
                }




                break;
        }
    }








    //发货地  +  目的地  联合使用
    public void showAddressPop(List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> data) {
        this.addressEntityList = data;
        if (isLoaded) {
            showCityPop();
        } else {
            mHandler.sendEmptyMessage(MSG_LOAD_DATA);
        }
    }


    public void showCityPop() {
        //条件选择器
        CityPickView cityOption = new CityPickBuilder(this, (options1, options2, options3, v) -> {
            String areaName;
            if (opt3.get(options1).get(options2).get(options3) == null) {
                areaName = "";
            } else{
                areaName = opt3.get(options1).get(options2).get(options3).getName();
                cityPosition3 = options3;
                //区
                viewModel.carriageInfoPublishEntity.get().setDestDistrictName(areaName);
                viewModel.carriageInfoPublishEntity.get().setDestDistrictNo(opt3.get(options1).get(options2).get(options3).getNo());
            }

            String content = addressEntityList.get(options1).getName()
                    + opt2.get(options1).get(options2).getName()
                    + areaName;
            if(choose==1){
                binding.itemTvDeliveryAddress.setContent(content);
            }
            if(choose==2){
                binding.itemTvPurposeAddress.setContent(content);
            }

            cityPosition1 = options1;
            cityPosition2 = options2;
            //省
            viewModel.carriageInfoPublishEntity.get().setDestProvinceName(addressEntityList.get(options1).getName());
            viewModel.carriageInfoPublishEntity.get().setDestProvinceNo(addressEntityList.get(options1).getNo());
            //市
            viewModel.carriageInfoPublishEntity.get().setDestCityName(opt2.get(options1).get(options2).getName());
            viewModel.carriageInfoPublishEntity.get().setDestCityNo(opt2.get(options1).get(options2).getNo());

        }).build();

        cityOption.setPicker(addressEntityList, opt2, opt3);
        cityOption.setSelectOptions(cityPosition1, cityPosition2, cityPosition3);
        cityOption.show();

    }


    private void initJsonData() {
        //城市列表
        List<AddressEntity<List<AddressEntity>>> cityList;
        //区域列表
        List<List<AddressEntity>> areaList;
        for (int x = 0; x < addressEntityList.size(); x++) {
            cityList = new ArrayList<>();
            areaList = new ArrayList<>();//
            if (viewModel.carriageInfoPublishEntity.get() != null && viewModel.carriageInfoPublishEntity.get().getDestProvinceName() != null && viewModel.carriageInfoPublishEntity.get().getDestProvinceName().equals(addressEntityList.get(x).getName())) {
                cityPosition1 = x;
            }
            opt2.add(addressEntityList.get(x).getChildren());
            for (int i = 0; i < addressEntityList.get(x).getChildren().size(); i++) {
                cityList.add(addressEntityList.get(x).getChildren().get(i));
                List<AddressEntity> cityAreaList = new ArrayList<>();
                //如果无地区数据，建议添加空字符串，防止数据为null 导致三个选项长度不匹配造成崩溃
                if (addressEntityList.get(x).getChildren().get(i).getChildren() == null
                        || addressEntityList.get(x).getChildren().get(i).getChildren().size() == 0) {
                    cityAreaList.add(null);
                } else {
                    cityAreaList.addAll(addressEntityList.get(x).getChildren().get(i).getChildren());
                }
                areaList.add(cityAreaList);
            }
            opt3.add(areaList);
        }
        if (viewModel.carriageInfoPublishEntity.get() != null) {
            if (viewModel.carriageInfoPublishEntity.get().getDestCityName() != null)
                for (int x2 = 0; x2 < opt2.size(); x2++) {
                    if (viewModel.carriageInfoPublishEntity.get().getDestCityName().equals(addressEntityList.get(cityPosition1).getChildren().get(x2).getName())) {
                        cityPosition2 = x2;
                        break;
                    }
                }
            if (viewModel.carriageInfoPublishEntity.get().getDestDistrictName() != null)
                for (int x3 = 0; x3 < opt3.size(); x3++) {
                    if (viewModel.carriageInfoPublishEntity.get().getDestDistrictName().equals(addressEntityList.get(cityPosition1).getChildren().get(cityPosition2).getChildren().get(x3).getName())) {
                        cityPosition3 = x3;
                        break;
                    }
                }
        }
        mHandler.sendEmptyMessage(MSG_LOAD_SUCCESS);
    }


    private Handler mHandler = new Handler() {
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_LOAD_DATA:
                    if (thread == null) {//如果已创建就不再重新创建子线程了
                        thread = new Thread(() -> {
                            // 子线程中解析省市区数据
                            initJsonData();
                        });
                        thread.start();
                    }
                    break;
                case MSG_LOAD_SUCCESS:
                    showCityPop();
                    isLoaded = true;
                    thread = null;
                    break;
                case MSG_LOAD_FAILED:
                    break;
            }
        }
    };



    //是否自卸
    public void showIsDumpPop(List<CarriageSelectEntity> isDumpList) {
        this.isDumpList = isDumpList;
        showIsDumpPop();
    }

    private void showIsDumpPop() {
        OptionsPickerView businessOption = new OptionsPickerBuilder(OverbookingPublishActivity.this, (options1, options2, options3, v) -> {
            String content = carModelList.get(options1).getName();
            binding.itemTvUnloadingWay.setContent(content);
            isDumpPosition = options1;
//            viewModel.carriageInfoPublishEntity.get().setIsDump(isDumpList.get(options1).getNo());
        }).build();
        businessOption.setPicker(isDumpList);
        businessOption.setSelectOptions(isDumpPosition);
        businessOption.show();
    }


    //我的车型
    public void showCarModelPop(List<CarriageSelectEntity> carModelList) {
        this.carModelList = carModelList;
        showCarModelPop();
    }

    private void showCarModelPop() {
        OptionsPickerView businessOption = new OptionsPickerBuilder(OverbookingPublishActivity.this, (options1, options2, options3, v) -> {
            String content = carModelList.get(options1).getName();
            binding.itemTvRequirementsModels.setContent(content);
            carModelPosition = options1;
//            viewModel.carriageInfoPublishEntity.get().setCarTypeNo(carModelList.get(options1).getNo());
        }).build();
        businessOption.setPicker(carModelList);
        businessOption.setSelectOptions(carModelPosition);
        businessOption.show();
    }


    //时间选择器
    public void showTimePop() {
        TimePickerView timePicker = new TimePickerBuilder(OverbookingPublishActivity.this, (date, v) -> {
            @SuppressLint("SimpleDateFormat") SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String format = sdf.format(date);
            if (today == null)
                today = new Date();
            int compareTo = today.compareTo(date);
            if (compareTo == -1) {
                Toast.makeText(OverbookingPublishActivity.this, "请选择小于今天的日期", Toast.LENGTH_SHORT).show();
            } else {
                try {


                    if(time==1){
                        binding.itemTvStartTime.setContent(format);
                    }
                    if(time==2){
                        binding.itemTvEndTime.setContent(format);
                    }
                    selectedDate.setTime(date);
                    //时间戳
                    long times = DateUtils.dateTo10Timestamp(format);
                    MLog.d("time", times + "");
//                    viewModel.carriageInfoPublishEntity.get().setInTime(format + "");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).build();
        timePicker.show();
        timePicker.setDate(selectedDate);
    }


    //货物类型
    public void showGoodsType(List<GoodsSelectEntity> data) {
        this.goodsList = data;
        showGoodsType();
    }

    private void showGoodsType() {

        OptionsPickerView optionsPickerView = new OptionsPickerBuilder(OverbookingPublishActivity.this, (options1, options2, options3, v) -> {
            String content = goodsList.get(options1).getName();
            binding.itemTvGoodsType.setContent(content);
            goodsModelPosition = options1;
//            viewModel.carriageInfoPublishEntity.get().setCarTypeNo(goodsList.get(options1).getNo());
        }).build();
        optionsPickerView.setPicker(goodsList);
        optionsPickerView.setSelectOptions(goodsModelPosition);
        optionsPickerView.show();
    }


    //我的车长
    public void showCarLengthPop(List<CarriageSelectEntity> carLengthList) {
        this.carLengthList = carLengthList;
        showCarLengthPop();
    }

    private void showCarLengthPop() {
        OptionsPickerView businessOption = new OptionsPickerBuilder(OverbookingPublishActivity.this, (options1, options2, options3, v) -> {
            String content = carLengthList.get(options1).getName();
            binding.itemTvRequirementsConductor.setContent(content);
            carLengthPosition = options1;
//            viewModel.carriageInfoPublishEntity.get().setCarLenNo(carLengthList.get(options1).getNo());
        }).build();
        businessOption.setPicker(carLengthList);
        businessOption.setSelectOptions(carLengthPosition);
        businessOption.show();
    }

    //装卸方式
    public void showhandlingType(List<GoodsInfoTypeEntity3> data) {
        this.handlingType=data;
        showhandlingType();
    }

    private void showhandlingType() {
        OptionsPickerView businessOption = new OptionsPickerBuilder(OverbookingPublishActivity.this, (options1, options2, options3, v) -> {
            String content = handlingType.get(options1).getName();
            binding.itemTvUnloadingWay.setContent(content);
            handlingTypePosition = options1;
//            viewModel.carriageInfoPublishEntity.get().setCarLenNo(handlingType.get(options1).getNo());
        }).build();
        businessOption.setPicker(handlingType);
        businessOption.setSelectOptions(handlingTypePosition);
        businessOption.show();
    }



    //付款方式
    public void showPayType(List<GoodsInfoTypeEntity3> data) {
        this.PayType=data;
        showPayType();
    }

    private void showPayType() {
        OptionsPickerView businessOption = new OptionsPickerBuilder(OverbookingPublishActivity.this, (options1, options2, options3, v) -> {
            String content = PayType.get(options1).getName();
            binding.itemTvTermsPayment.setContent(content);
            PayTypePosition = options1;
//            viewModel.carriageInfoPublishEntity.get().setCarLenNo(PayType.get(options1).getNo());
        }).build();
        businessOption.setPicker(PayType);
        businessOption.setSelectOptions(PayTypePosition);
        businessOption.show();
    }



    //发票要求
    public void showInvoiceType(List<CarriageSelectEntity> data) {
        this.InvoiceType=data;
        showInvoiceType();
    }

    private void showInvoiceType() {
        OptionsPickerView businessOption = new OptionsPickerBuilder(OverbookingPublishActivity.this, (options1, options2, options3, v) -> {
            String content = InvoiceType.get(options1).getName();
            binding.itemTvInvoiceRequirements.setContent(content);
            InvoiceTypePosition = options1;
//            viewModel.carriageInfoPublishEntity.get().setCarLenNo(InvoiceType.get(options1).getNo());
        }).build();
        businessOption.setPicker(InvoiceType);
        businessOption.setSelectOptions(InvoiceTypePosition);
        businessOption.show();
    }


    //运输方式
    public void showTransType(List<GoodsInfoTypeEntity3> data) {
        this.TransType=data;
        showTransType();
    }

    private void showTransType() {
        OptionsPickerView businessOption = new OptionsPickerBuilder(OverbookingPublishActivity.this, (options1, options2, options3, v) -> {
            String content = TransType.get(options1).getName();
            binding.itemTvTransportRequirements.setContent(content);
            TransTypePosition = options1;
//            viewModel.carriageInfoPublishEntity.get().setCarLenNo(TransType.get(options1).getNo());
        }).build();
        businessOption.setPicker(TransType);
        businessOption.setSelectOptions(TransTypePosition);
        businessOption.show();
    }


    //选择货源popWindow
    public void showGoodsSource(List<MapGoodsBiddingEntity> goodsSourceList) {
        this.goodsSourceList= goodsSourceList;
        showGoodsPop(true);
    }

    private void showGoodsPop(boolean goodsSource) {
        if (!goodsSourceWindow.isShowing()) {
            goodsSourceWindow.showDownPopwindow(binding.grayLayout, true);
        }
        goodsSourceWindow.setData(goodsSourceList, -1);
    }

}
